package com.esd.device.controller;

import com.esd.common.pojo.R;
import com.esd.device.entity.dto.AnalysisSearch;
import com.esd.device.entity.dto.EsdLogSearch;
import com.esd.device.service.EsdLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/esdLogAdmin")
public class EsdLogAdminController {

    @Autowired
    private EsdLogService esdLogService ;

    @PostMapping("logSearch")
    public R logSearch(
            @RequestBody EsdLogSearch esdLogSearch
    ){
        return esdLogService.logSearch(esdLogSearch) ;
    }

    @PostMapping("searchData")
    public R searchData(@RequestBody AnalysisSearch analysisSearch){
        Map<String , Object> result = esdLogService.searchData(analysisSearch) ;
        return R.ok(result) ;
    }

    @PostMapping("exportData")
    public void exportData(
            @RequestBody AnalysisSearch analysisSearch ,
            HttpServletResponse response) throws IOException {
        esdLogService.exportData(analysisSearch, response);
    }
}
